Exemplo n.º 1
0
def delete(invoiceId, stationaryItemId):
    if Invoice.has_confirmed(invoiceId):
        raise ForbiddenException("Stationary items cannot be deleted from confirmed invoices (%d)" % invoiceId)
    else:
        result = Model.query.filter(
            Model.invoiceId == invoiceId,
            Model.stationaryItemId == stationaryItemId
        ).delete()

        db.session.flush()

        return result
Exemplo n.º 2
0
    def __init__(self, invoiceId, stationaryItemId):
        if Invoice.has_confirmed(invoiceId):
            raise ForbiddenException("Stationary items cannot be added to confirmed invoices (%d)" % invoiceId)
        elif StationaryItem.is_locked(stationaryItemId):
            raise ForbiddenException("Stationary item is not available (%d)" % stationaryItemId)
        else:
            received_proof = Proof.create(
                proofType=ProofTypeEnum.InvoiceStationaryItemReceive
            )

            super(InvoiceStationaryItemModel, self).__init__(
                invoiceId=invoiceId,
                stationaryItemId=stationaryItemId,
                receivedProofId=received_proof.proofId
            )
def create(invoiceId, stationaryItemId):
    if Invoice.has_confirmed(invoiceId):
        raise ForbiddenException("Stationary items cannot be added to confirmed invoices (%d)" % invoiceId)
    elif StationaryItem.is_locked(stationaryItemId):
        raise ForbiddenException("Stationary item is not available (%d)" % stationaryItemId)
    else:
        received_proof = Proof.create(
            proofType=ProofTypeEnum.InvoiceStationaryItemReceive
        )

        print("######################### received_proof ###", received_proof)
        print("######################### received_proof.proofId ###", received_proof.proofId)

        result = Model(
            invoiceId=invoiceId,
            stationaryItemId=stationaryItemId,
            receivedProofId=received_proof.proofId
        )

        db.session.add(result)
        db.session.commit()

        return result