forked from adempiere/proxy-adempiere-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: List Product Attribute Instances. (adempiere#62)
* feat: List Product Attribute Instances. * feat: Add get Product Attribute Set. * update package.json
- Loading branch information
1 parent
7675a6f
commit 08bfcab
Showing
4 changed files
with
196 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
src/modules/adempiere-api/api/extensions/adempiere/util/convertMaterialManagement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/************************************************************************************ | ||
* Copyright (C) 2012-2022 E.R.P. Consultores y Asociados, C.A. * | ||
* Contributor(s): Edwin Betancourt [email protected] * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. * | ||
************************************************************************************/ | ||
|
||
export function convertProductAttributeValue (productAttributeValue) { | ||
if (!productAttributeValue) { | ||
return undefined | ||
} | ||
|
||
return { | ||
id: productAttributeValue.getId(), | ||
uuid: productAttributeValue.getUuid(), | ||
value: productAttributeValue.getValue(), | ||
name: productAttributeValue.getName(), | ||
description: productAttributeValue.getDescription() | ||
} | ||
} | ||
|
||
export function convertProductAttribute (productAttribute) { | ||
if (!productAttribute) { | ||
return undefined | ||
} | ||
|
||
return { | ||
id: productAttribute.getId(), | ||
uuid: productAttribute.getUuid(), | ||
name: productAttribute.getName(), | ||
description: productAttribute.getDescription(), | ||
value_type: productAttribute.getValueType(), | ||
is_mandatory: productAttribute.getIsMandatory(), | ||
is_instance_attribute: productAttribute.getIsInstanceAttribute(), | ||
sequence: productAttribute.getSequence(), | ||
product_attribute_values: productAttribute.getProductAttributeValuesList().map(productAttributeValue => { | ||
return convertProductAttributeValue(productAttributeValue) | ||
}) | ||
} | ||
} | ||
|
||
export function convertProductAttributeSet (productAttributeSet) { | ||
if (!productAttributeSet) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
id: productAttributeSet.getId(), | ||
uuid: productAttributeSet.getUuid(), | ||
name: productAttributeSet.getName(), | ||
description: productAttributeSet.getDescription(), | ||
is_instance_attribute: productAttributeSet.getIsInstanceAttribute(), | ||
is_lot: productAttributeSet.getIsLot(), | ||
is_lot_mandatory: productAttributeSet.getIsLotMandatory(), | ||
lot_control_id: productAttributeSet.getLotControlId(), | ||
lot_char_start_overwrite: productAttributeSet.getLotCharStartOverwrite(), | ||
lot_char_end_overwrite: productAttributeSet.getLotCharEndOverwrite(), | ||
// Serial Attributes | ||
is_serial: productAttributeSet.getIsSerial(), | ||
is_serial_mandatory: productAttributeSet.getIsSerialMandatory(), | ||
serial_control_id: productAttributeSet.getSerialControlId(), | ||
serial_char_start_overwrite: productAttributeSet.getSerialCharStartOverwrite(), | ||
serial_char_end_overwrite: productAttributeSet.getSerialCharEndOverwrite(), | ||
// Guarantee Date Attributes | ||
is_guarantee_date: productAttributeSet.getIsGuaranteeDate(), | ||
is_guarantee_date_mandatory: productAttributeSet.getIsGuaranteeDateMandatory(), | ||
guarantee_days: productAttributeSet.getGuaranteeDays(), | ||
madatory_type: productAttributeSet.getMandatoryType(), | ||
product_attributes: productAttributeSet.getProductAttributesList().map(productAttribute => { | ||
return convertProductAttribute(productAttribute) | ||
}) | ||
} | ||
} | ||
|
||
export function convertProductAttributeSetInstance (productAttributeSetInstance) { | ||
if (!productAttributeSetInstance) { | ||
return undefined | ||
} | ||
|
||
return { | ||
id: productAttributeSetInstance.getId(), | ||
uuid: productAttributeSetInstance.getUuid(), | ||
description: productAttributeSetInstance.getDescription(), | ||
guarantee_date: productAttributeSetInstance.getGuaranteeDate(), | ||
lot: productAttributeSetInstance.getLot(), | ||
lot_id: productAttributeSetInstance.getLotId(), | ||
serial: productAttributeSetInstance.getSerial(), | ||
product_attribute_set: convertProductAttributeSet( | ||
productAttributeSetInstance.getProductAttributeSet() | ||
) | ||
} | ||
} | ||
|
||
export function convertListProductAttributeSetInstances (productAttributeSetInstancesList) { | ||
return { | ||
record_count: productAttributeSetInstancesList.getRecordCount(), | ||
next_page_token: productAttributeSetInstancesList.getNextPageToken(), | ||
records: productAttributeSetInstancesList.getRecordsList().map(productAttributeSetInstance => { | ||
return convertProductAttributeSetInstance(productAttributeSetInstance); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,10 @@ | |
striptags "^3.0.1" | ||
word-wrap "^1.2.1" | ||
|
||
"@adempiere/[email protected].3": | ||
version "3.5.3" | ||
resolved "https://registry.yarnpkg.com/@adempiere/grpc-api/-/grpc-api-3.5.3.tgz#372de5ff714511364dbf2d6d12dd27b6b237acb2" | ||
integrity sha512-3/os3howhix3O8RBBajXiCxXKcxFwCEHZywrClNQKlouhqFNgviOL19JShKxjr3OjwYtcaKZhiuIWFefQdxnDw== | ||
"@adempiere/[email protected].4": | ||
version "3.5.4" | ||
resolved "https://registry.yarnpkg.com/@adempiere/grpc-api/-/grpc-api-3.5.4.tgz#9a09a9e5f3d9bf5b5da0414dc76ae417571889d4" | ||
integrity sha512-kWpq9vHDrP6OBDUOwK6hoXnKOTxmlUnSDK2Pc93tkNe8eG7cz84yAd8qIP4a6yKq6UsPWYGQ8brAtTkWRjspDQ== | ||
dependencies: | ||
"@grpc/grpc-js" "1.7.0" | ||
google-protobuf "3.21.0" | ||
|