This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into gh145-app
- Loading branch information
Showing
7 changed files
with
267 additions
and
37 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
cypress/integration/purchase/credit_memo_for_purchase_invoice.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,64 @@ | ||
/* | ||
* #%L | ||
* metasfresh-e2e | ||
* %% | ||
* Copyright (C) 2019 metas GmbH | ||
* %% | ||
* 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 | ||
* <http://www.gnu.org/licenses/gpl-2.0.html>. | ||
* #L% | ||
*/ | ||
|
||
/// <reference types="Cypress" /> | ||
|
||
import {getLanguageSpecific} from '../../support/utils/utils'; | ||
import {DocumentActionKey, DocumentStatusKey} from '../../support/utils/constants'; | ||
import {PurchaseInvoice, PurchaseInvoiceLine} from "../../support/utils/purchase_invoice"; | ||
|
||
describe('Create a Credit memo for Purchase Invoice', function() { | ||
const creditMemoVendor = 'Credit Memo (Vendor)'; | ||
const businessPartnerName = 'Test Lieferant 1'; | ||
const productName = 'Convenience Salat 250g'; | ||
const quantity = 200; | ||
|
||
it(`Ensure ${creditMemoVendor} is Number Controlled`, function() { | ||
// very bold assumption that this document type always has recordId=1000006 | ||
cy.visitWindow('135', '1000006'); | ||
cy.setCheckBoxValue('IsDocNoControlled', true); | ||
}); | ||
|
||
it('Prepare Purchase Invoice', function() { | ||
cy.fixture('misc/misc_dictionary.json').then(miscDictionary => { | ||
new PurchaseInvoice(businessPartnerName, creditMemoVendor) | ||
.addLine( | ||
new PurchaseInvoiceLine().setProduct(productName).setQuantity(quantity) | ||
) | ||
.setDocumentAction(getLanguageSpecific(miscDictionary, DocumentActionKey.Complete)) | ||
.setDocumentStatus(getLanguageSpecific(miscDictionary, DocumentStatusKey.Completed)) | ||
.apply(); | ||
}); | ||
}); | ||
|
||
it('Purchase Invoice is Completed', function() { | ||
cy.expectDocumentStatus(DocumentStatusKey.Completed); | ||
}); | ||
|
||
it('Purchase Invoice is not paid', function() { | ||
cy.getCheckboxValue('IsPaid').then(checkBoxValue => { | ||
cy.log(`IsPaid = ${checkBoxValue}`); | ||
assert.equal(checkBoxValue, false); | ||
}); | ||
}); | ||
|
||
}); |
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
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
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,160 @@ | ||
export class PurchaseInvoice { | ||
constructor(businessPartnerName, targetDocumentType) { | ||
cy.log(`PurchaseInvoice - businessPartnerName=${businessPartnerName}, targetDocumentType=${targetDocumentType}`); | ||
this.businessPartner = businessPartnerName; | ||
this.targetDocumentType = targetDocumentType; | ||
this._toString = `businessPartnerName=${businessPartnerName}, targetDocumentType=${targetDocumentType}`; | ||
this.lines = []; | ||
} | ||
|
||
addLine(purchaseInvoiceLine) { | ||
//console.log(`PurchaseInvoice - add InvoiceLine = ${JSON.stringify(purchaseInvoiceLine)}`); | ||
this.lines.push(purchaseInvoiceLine); | ||
return this; | ||
} | ||
|
||
setDocumentAction(documentAction) { | ||
this.documentAction = documentAction; | ||
return this; | ||
} | ||
|
||
setDocumentStatus(documentStatus) { | ||
this.documentStatus = documentStatus; | ||
return this; | ||
} | ||
|
||
setPriceList(priceList) { | ||
this.priceList = priceList; | ||
return this; | ||
} | ||
|
||
/** Creates a new invoice and stores its documentId as alias newInvoiceDocumentId. */ | ||
apply() { | ||
cy.log(`PurchaseInvoice - apply START (${this._toString})`); | ||
PurchaseInvoice.applyPurchaseInvoice(this); | ||
cy.log(`PurchaseInvoice - apply STOP (${this._toString})`); | ||
} | ||
|
||
static applyPurchaseInvoice(purchaseInvoice) { | ||
describe(`Create new PurchaseInvoice: ${purchaseInvoice._toString}`, () => { | ||
cy.visitWindow('183', 'NEW', 'newInvoiceDocumentId' /*documentIdAliasName*/); | ||
|
||
cy.get('.header-breadcrumb-sitename') | ||
.should('contain', new Date().getDate()) | ||
.should('contain', new Date().getFullYear()); | ||
|
||
cy.writeIntoLookupListField('C_BPartner_ID', purchaseInvoice.businessPartner, purchaseInvoice.businessPartner); | ||
|
||
cy.getStringFieldValue('M_PriceList_ID').should('not.be.empty'); | ||
cy.getStringFieldValue('C_Currency_ID').should('not.be.empty'); | ||
if (purchaseInvoice.priceList) { | ||
cy.selectInListField('M_PriceList_ID', purchaseInvoice.priceList); | ||
} | ||
|
||
cy.getStringFieldValue('DocumentNo').should('be.empty'); | ||
cy.selectInListField('C_DocTypeTarget_ID', purchaseInvoice.targetDocumentType); | ||
cy.getStringFieldValue('DocumentNo').should('not.be.empty'); | ||
|
||
purchaseInvoice.lines.forEach(line => { | ||
PurchaseInvoice.applyLine(line); | ||
}); | ||
|
||
if (purchaseInvoice.documentAction) { | ||
if (purchaseInvoice.documentStatus) { | ||
cy.processDocument(purchaseInvoice.documentAction, purchaseInvoice.documentStatus); | ||
} else { | ||
cy.processDocument(purchaseInvoice.documentAction); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Possible workaround for applyLine_buggy: | ||
* It could be that setting the qty before setting the product id will fix the issue where 'done' button is pressed BEFORE | ||
* the QtyEntered is saved. | ||
* | ||
* This is just a workaround though which isn't very cool to use. | ||
*/ | ||
static applyLine(purchaseInvoiceLine) { | ||
cy.selectTab('C_InvoiceLine'); | ||
cy.pressAddNewButton(); | ||
|
||
cy.writeIntoStringField( | ||
'QtyEntered', | ||
purchaseInvoiceLine.quantity, | ||
true /*modal*/, | ||
null /*rewriteUrl*/, | ||
true /*noRequest, bc the patch response is e.g. 20 and we would be waiting for e.g. '20' */ | ||
); | ||
// instead of waiting for the patch in writeIntoStringField, we wait for the "pending" indicator to go away | ||
cy.get('.indicator-pending').should('not.exist'); | ||
|
||
cy.writeIntoLookupListField( | ||
'M_Product_ID', | ||
purchaseInvoiceLine.product, | ||
purchaseInvoiceLine.product, | ||
false /*typeList*/, | ||
true /*modal*/ | ||
); | ||
|
||
if (purchaseInvoiceLine.tuQuantity) { | ||
cy.writeIntoStringField('QtyEnteredTU', purchaseInvoiceLine.tuQuantity, true /*modal*/); | ||
} | ||
if (purchaseInvoiceLine.packingItem) { | ||
cy.writeIntoLookupListField( | ||
'M_HU_PI_Item_Product_ID', | ||
purchaseInvoiceLine.packingItem, | ||
purchaseInvoiceLine.packingItem, | ||
false /*typeList*/, | ||
true /*modal*/ | ||
); | ||
} | ||
cy.pressDoneButton(); | ||
} | ||
|
||
/* | ||
static applyLine_buggy(purchaseInvoiceLine) { | ||
cy.selectTab('C_InvoiceLine'); | ||
cy.pressAddNewButton(); | ||
cy.writeIntoLookupListField('M_Product_ID', purchaseInvoiceLine.product, purchaseInvoiceLine.product); | ||
cy.writeIntoStringField('QtyEntered', purchaseInvoiceLine.quantity, true, null, true); | ||
if (purchaseInvoiceLine.packingItem) { | ||
cy.writeIntoLookupListField('M_HU_PI_Item_Product_ID', purchaseInvoiceLine.packingItem, purchaseInvoiceLine.packingItem, true, true); | ||
} | ||
if (purchaseInvoiceLine.tuQuantity) { | ||
cy.writeIntoStringField('QtyEnteredTU', purchaseInvoiceLine.tuQuantity, true, null, true); | ||
} | ||
// something's flaky around here and, it seems that i need this delay as 'QtyEntered' or 'QtyEnteredTU' is sometimes NOT updated (it remains 1). | ||
// problem is it only happens sometimes :(. | ||
// how to fix? i'm not sure :( (is there a function "wait_until_all_requests_are_finished_before_pressing_done" ? maybe that helps) | ||
// how to quickly test? ask me and i'll help. | ||
cy.wait(5000); | ||
cy.pressDoneButton(); | ||
} | ||
*/ | ||
} | ||
|
||
export class PurchaseInvoiceLine { | ||
setProduct(product) { | ||
this.product = product; | ||
return this; | ||
} | ||
|
||
setPackingItem(packingItem) { | ||
this.packingItem = packingItem; | ||
return this; | ||
} | ||
|
||
setQuantity(quantity) { | ||
this.quantity = quantity; | ||
return this; | ||
} | ||
|
||
setTuQuantity(tuQuantity) { | ||
this.tuQuantity = tuQuantity; | ||
return this; | ||
} | ||
} |
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